
<?php $__env->startSection('content'); ?>
    <div class="x-nav">
            <span class="layui-breadcrumb">
                <a href="">首页</a>
                <a href="">演示</a>
                <a>
                    <cite>导航元素</cite></a>
            </span>
        <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
            <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
        </a>
    </div>
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-body ">
                        <table class="layui-table layui-form">
                            <thead>
                            <tr>
                                <th width="70">ID</th>
                                <th>商品名称</th>
                                <th>图片</th>
                                <th>分类ID</th>
                                <th>价格</th>
                                <th>库存数量</th>
                                <th width="250">操作</th>
                            </thead>
                            <?php foreach ($data as $key=>$v){?>
                            <tbody class="x-cate">
                            <tr cate-id='1' fid='0' >
                                <td><?=$v['id'] ?></td>
                                <td><?=$v['title'] ?></td>
                                <td><img src="<?=$v['img'] ?>" alt="" style="width: 80px;height: 80px"></td>
                                <td><?=$v['catagory_id'] ?></td>
                                <td><?=$v['price'] ?></td>
                                <td><?=$v['inventory'] ?></td>
                                <td class="td-manage">
                                    <button class="layui-btn layui-btn layui-btn-xs"  onclick="xadmin.open('编辑','<?php echo e(route('save',['id'=>$v->id])); ?>')" ><i class="layui-icon">&#xe642;</i>编辑1</button>
                                    <form action="<?php echo e(route('proDel',['id'=>$v->id])); ?>" method="post">
                                        <?php echo e(csrf_field()); ?>

                                        <?php echo e(method_field('DELETE')); ?>

                                        <input type="submit" value="删除" class="layui-btn-danger layui-btn layui-btn-xs">
                                    </form>
                                </td>
                            </tr>
                            </tbody>
                            <?php } ?>
                            <button class="layui-btn layui-btn layui-btn-xs"  onclick="xadmin.open('添加','<?php echo e(route('insert')); ?>')" ><i class="layui-icon">[+]</i>添加</button>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
    </div>
    <script>
        layui.use(['form'], function(){
            form = layui.form;
        });

        /*用户-删除*/
        function member_del(obj,id){
            layer.confirm('确认要删除吗？',function(index){
                //发异步删除数据
                $(obj).parents("tr").remove();
                layer.msg('已删除!',{icon:1,time:1000});
            });
        }

        // 分类展开收起的分类的逻辑
        //
        $(function(){
            $("tbody.x-cate tr[fid!='0']").hide();
            // 栏目多级显示效果
            $('.x-show').click(function () {
                if($(this).attr('status')=='true'){
                    $(this).html('&#xe625;');
                    $(this).attr('status','false');
                    cateId = $(this).parents('tr').attr('cate-id');
                    $("tbody tr[fid="+cateId+"]").show();
                }else{
                    cateIds = [];
                    $(this).html('&#xe623;');
                    $(this).attr('status','true');
                    cateId = $(this).parents('tr').attr('cate-id');
                    getCateId(cateId);
                    for (var i in cateIds) {
                        $("tbody tr[cate-id="+cateIds[i]+"]").hide().find('.x-show').html('&#xe623;').attr('status','true');
                    }
                }
            })
        })

        var cateIds = [];
        function getCateId(cateId) {
            $("tbody tr[fid="+cateId+"]").each(function(index, el) {
                id = $(el).attr('cate-id');
                cateIds.push(id);
                getCateId(id);
            });
        }

    </script>
    </body>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('master.index', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>